\section{Obtaining and building the PCIe Engine}
The repository is divided in several directories:
\begin{table}[H]
	\centering
	\begin{tabularx}{\textwidth}{|l|X|}
	\hline
	\textbf{directory}&\textbf{contents}\\
	\hline
	firmware/constraints&Contains an XDC file with Vivado constraints including Chipscope ILA definitions, may differ over different commits\\
	\hline
	firmware/output&Empty placeholder where bit files will be generated\\
	\hline
	firmware/Projects&Empty placeholder where the Vivado projects will be generated\\
	\hline
	firmware/scripts/Wupper&This directory contains two scripts per hardware type to create the vivado project and to run synthesis and implementation, see later this chapter.\\
	\hline
	firmware/simulation/Wupper&Contains a Modelsim.ini project as well as the scripts ci.sh to run the simulation in Modelsim (or Questasim)\\
	\hline
	firmware/sources/pcie&This directory contains the files for the Wupper PCIe core\\
	\hline
	firmware/sources/packages&Contains a vhdl package with some type definitions, but more importantly the application specific register definitions.\\
	\hline		
	
	\end{tabularx}
	\caption{Directories in the repository}\label{tab:directories}
\end{table}


\subsection{Clone the git repository}
Before starting to work with this core, it is a good idea to clone the whole GIT repository, if you already have it, update to the latest revision.
\begin{lstlisting}[frame=single, language=Bash, caption=git clone]
git clone https://gitlab.nikhef.nl/franss/wupper.git
\end{lstlisting}
besides the firmware directory with the listing in the introduction of this chapter, you will find other directories:\\
\begin{itemize}
\item \textbf{documentation} contains this document as well as a doxygen script to document the firmware structure.
\item \textbf{software}
	\begin{itemize}
		\item \textbf{driver} contains the wupper and cmem driver, described in \ref{sec:buildloadDrivers}
		\item \textbf{wupper\_tools} contains several useful tools to control DMA, the registers and application specific example tools
	\end{itemize}
\end{itemize}

\subsection{Create the Vivado Project}
The Vivado project is not supplied in the got tree, instead a .tcl script is provided to generate the project. To create the project, open Vivado without a project, then open the TCL console and run the following commands.
\begin{lstlisting}[frame=single, language=tcl,     caption=Create Vivado Project]
cd /path/to/felix/firmware/scripts/Wupper/
source ./VC709_import_vivado
\end{lstlisting}
A project should now be created in \textit{firmware/Projects/}. \textbf{beware that this script will overwrite and recreate the project if it exists already.}

\subsection{Running synthesis and implementation}
When the project has been created, you can simply press the buttons to run synthesis and implementation of the design, but a tcl script has been created to run these steps automatically. Additionally the script will create the bitfile in the \textit{firmware/output} directory, as well as an .mcs file and an .ltx file, containing the ChipScope ILA probes. All those 3 files have a timestamp in their filename so any previous synthesis output will be maintained.
The script can simply be executed if the project is open. 
\begin{lstlisting}[frame=single, language=tcl, caption=start synthesis / implementation]
cd /path/to/felix/firmware/scripts/Wupper/
source ./do_implementation_VC709.tcl
\end{lstlisting}
\newpage


